/*
 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#pragma once

#include <memory>
#include <vector>

#include "api/scoped_refptr.h"
#include "modules/video_capture/video_capture.h"
#include "rtc_base/logging.h"
#include "capturer_video_source.hpp"

namespace p2pms 
{

//==================================================================================================
// 
//==================================================================================================
class VideoCapturer 
  : public CapturerVideoSource
  , public rtc::VideoSinkInterface<webrtc::VideoFrame> 
{
public:
  static VideoCapturer* Create(size_t width, size_t height, size_t fps, const std::string& device_id);
  virtual ~VideoCapturer();

  void OnFrame(const webrtc::VideoFrame& frame) override;

private:
  VideoCapturer();
  bool Init(size_t width, size_t height, size_t fps, const std::string& device_id);
  void Destroy();

  size_t m_width;
  size_t m_height;
  rtc::scoped_refptr<webrtc::VideoCaptureModule> m_vcm;
  webrtc::VideoCaptureCapability m_capability;
};

}  // namespace p2pms
